; ---Includes
include lib1_1.asm

.MODEL small ;one data, one code segment, stack and data segment are grouped
.STACK 1024 ;stack, 1024 bytes

; --- Macros

.DATA ;data segment, static variables
; --- Constants

; --- Types

; --- Variables	
	InstalVar
	menux dw 130
	starty dw 40
	highscy dw 70
	creditsy dw 100
	quity dw 130
	sizex dw 60
	sizey dw 20	
	color db 5
	
.CODE ;code segment
.STARTUP ; start main, sets ds to beginning of data segment, updates ss to ds and adjusts sp acordingly	

	MSetVideoMode 13h
	MInitMouse
	mov cx,2
draw:
	;Clear previous mouse pointer
	MDrawRect 0,mousex,mousey,2,2
	MUpdateMouse
	;Calculate
	mov color,5
	
; Start knop
	MPointInRect mousex,mousey,menux,starty,sizex,sizey,notinstart,instart
notinstart:	
	jmp endcheckstart
instart:
	mov color,120
	mov ax,1
	cmp ax,mousestate
	jne endcheckstart
	; Start game when button is clicked
endcheckstart:
	;Draw rectangle
	MDrawRect color,menux,starty,sizex,sizey
	mov color, 5;

;Highscores knop
	MPointInRect mousex,mousey,menux,highscy,sizex,sizey,notinhigh,inhigh
notinhigh:	
	jmp endcheckhigh
inhigh:
	mov color,120
	mov ax,1
	cmp ax,mousestate
	jne endcheckhigh
	; Do stuff when clicked on this button
endcheckhigh:
	;Draw rectangle
	MDrawRect color,menux,highscy,sizex,sizey
	mov color, 5;
	
; Credits knop
	MPointInRect mousex,mousey,menux,creditsy,sizex,sizey,notincredits,incredits
notincredits:	
	jmp endcheckcredits
incredits:
	mov color,120
	mov ax,1
	cmp ax,mousestate
	jne endcheckcredits
	; Do stuff when clicked on this button
endcheckcredits:
	;Draw rectangle
	MDrawRect color,menux,creditsy,sizex,sizey
	mov color, 5;
	
; Quit knop
	MPointInRect mousex,mousey,menux,quity,sizex,sizey,notinquit,inquit
notinquit:	
	jmp endcheckquit
inquit:
	mov color,120
	mov ax,1
	cmp ax,mousestate
	jne endcheckquit
	; Quit game when button is clicked
endcheckquit:
	;Draw rectangle
	MDrawRect color,menux,quity,sizex,sizey

	;Draw Mouse pointer
	MDrawRect 1,mousex,mousey,2,2
	MUpdateScreenMode13
	cmp cx,mousestate	; if the second mouse button is pushed the loop ends
jne draw
	MRestoreVideoMode	
.EXIT
; ---Procedures
	InstalPrintInt
	InstalRandInt
	IntstalCopyData
	InstalDrawRect
END
